%Declare the symbolic variables (syms)
syms lambdaVal shkpVal cVal %c0Val shkmuVal

f=Lambdastar*exp(lambdaVal)-exp(shkpVal)/(Cstar*exp(cVal));

%Lambdastar*exp(lambdaVal)-exp(shkpVal)/(Cstar*exp(cVal)-habit*Cstar*exp(c0Val)/exp(mustar100/100)/exp(shkmuVal));
%old one with habits

%Take symbolic derivatives
dd1 = diff(f,lambdaVal);
dd2 = diff(f,shkpVal);
dd3 = diff(f,cVal);
%dd4 = diff(f,c0Val);
%dd5 = diff(f,shkmuVal);

%Evaluates symbolic derivatives

lambdaVal=0;  %loglin
shkpVal=0;  %loglin
cVal=0;  %loglin
%c0Val=0;  %loglin
%shkmuVal=0;  %loglin

D1=subs(dd1);
D2=subs(dd2);
D3=subs(dd3);
%D4=subs(dd4);
%D5=subs(dd5);

% Transform symbolic into numbers (with double precision)
d1=double(D1);
d2=double(D2);
d3=double(D3);
%d4=double(D4);
%d5=double(D5);

ACont(3,LambdaLog)   = -d1;
ACont(3,shkpLog)     = -d2;
ACont(3,cLog)        = -d3;
%ALag(3,cLog)     = d4;
%ACont(3,shkmuLog)   = -d5;
